var _ = require('underscore')


exports.index = function(req, res, next) {
  var begin = req.query.begin,
    end = req.query.end,
    interval = req.query.interval,
    size = req.query.size
  if (size === '1') {
    showTopbar(res)
  }else{
    showChart(res)
  }

}

function showChart(res) {
  res.json({
    "result": [{
      "combData": {
        "count": 2,
        "et": 1430971200000,
        "max": 3.093,
        "min": 0.969,
        "st": 1430881200000,
        "total": 4.062
      },
      "data": [{
        "count": 1,
        "et": 1430884800000,
        "max": 3.093,
        "min": 3.093,
        "st": 1430881200000,
        "total": 3.093
      }, {
        "count": 0,
        "et": 1430888400000,
        "max": 0,
        "min": 0,
        "st": 1430884800000,
        "total": 0
      }, {
        "count": 1,
        "et": 1430892000000,
        "max": 0.969,
        "min": 0.969,
        "st": 1430888400000,
        "total": 0.969
      }, {
        "count": 0,
        "et": 1430895600000,
        "max": 0,
        "min": 0,
        "st": 1430892000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430899200000,
        "max": 0,
        "min": 0,
        "st": 1430895600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430902800000,
        "max": 0,
        "min": 0,
        "st": 1430899200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430906400000,
        "max": 0,
        "min": 0,
        "st": 1430902800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430910000000,
        "max": 0,
        "min": 0,
        "st": 1430906400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430913600000,
        "max": 0,
        "min": 0,
        "st": 1430910000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430917200000,
        "max": 0,
        "min": 0,
        "st": 1430913600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430920800000,
        "max": 0,
        "min": 0,
        "st": 1430917200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430924400000,
        "max": 0,
        "min": 0,
        "st": 1430920800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430928000000,
        "max": 0,
        "min": 0,
        "st": 1430924400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430931600000,
        "max": 0,
        "min": 0,
        "st": 1430928000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430935200000,
        "max": 0,
        "min": 0,
        "st": 1430931600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430938800000,
        "max": 0,
        "min": 0,
        "st": 1430935200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430942400000,
        "max": 0,
        "min": 0,
        "st": 1430938800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430946000000,
        "max": 0,
        "min": 0,
        "st": 1430942400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430949600000,
        "max": 0,
        "min": 0,
        "st": 1430946000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430953200000,
        "max": 0,
        "min": 0,
        "st": 1430949600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430956800000,
        "max": 0,
        "min": 0,
        "st": 1430953200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430960400000,
        "max": 0,
        "min": 0,
        "st": 1430956800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430964000000,
        "max": 0,
        "min": 0,
        "st": 1430960400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430967600000,
        "max": 0,
        "min": 0,
        "st": 1430964000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430971200000,
        "max": 0,
        "min": 0,
        "st": 1430967600000,
        "total": 0
      }],
      "key": {
        "id": 64737,
        "name": "ForumHomePage#onCreate"
      }
    }, {
      "combData": {
        "count": 288,
        "et": 1430971200000,
        "max": 2.272,
        "min": 0.185,
        "st": 1430881200000,
        "total": 158.18901
      },
      "data": [{
        "count": 1,
        "et": 1430884800000,
        "max": 2.272,
        "min": 2.272,
        "st": 1430881200000,
        "total": 2.272
      }, {
        "count": 209,
        "et": 1430888400000,
        "max": 0.957,
        "min": 0.185,
        "st": 1430884800000,
        "total": 86.057
      }, {
        "count": 3,
        "et": 1430892000000,
        "max": 0.889,
        "min": 0.59,
        "st": 1430888400000,
        "total": 2.245
      }, {
        "count": 75,
        "et": 1430895600000,
        "max": 2.234,
        "min": 0.318,
        "st": 1430892000000,
        "total": 67.61501
      }, {
        "count": 0,
        "et": 1430899200000,
        "max": 0,
        "min": 0,
        "st": 1430895600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430902800000,
        "max": 0,
        "min": 0,
        "st": 1430899200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430906400000,
        "max": 0,
        "min": 0,
        "st": 1430902800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430910000000,
        "max": 0,
        "min": 0,
        "st": 1430906400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430913600000,
        "max": 0,
        "min": 0,
        "st": 1430910000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430917200000,
        "max": 0,
        "min": 0,
        "st": 1430913600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430920800000,
        "max": 0,
        "min": 0,
        "st": 1430917200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430924400000,
        "max": 0,
        "min": 0,
        "st": 1430920800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430928000000,
        "max": 0,
        "min": 0,
        "st": 1430924400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430931600000,
        "max": 0,
        "min": 0,
        "st": 1430928000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430935200000,
        "max": 0,
        "min": 0,
        "st": 1430931600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430938800000,
        "max": 0,
        "min": 0,
        "st": 1430935200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430942400000,
        "max": 0,
        "min": 0,
        "st": 1430938800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430946000000,
        "max": 0,
        "min": 0,
        "st": 1430942400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430949600000,
        "max": 0,
        "min": 0,
        "st": 1430946000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430953200000,
        "max": 0,
        "min": 0,
        "st": 1430949600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430956800000,
        "max": 0,
        "min": 0,
        "st": 1430953200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430960400000,
        "max": 0,
        "min": 0,
        "st": 1430956800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430964000000,
        "max": 0,
        "min": 0,
        "st": 1430960400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430967600000,
        "max": 0,
        "min": 0,
        "st": 1430964000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430971200000,
        "max": 0,
        "min": 0,
        "st": 1430967600000,
        "total": 0
      }],
      "key": {
        "id": 64757,
        "name": "SplashActivity#onCreate"
      }
    }, {
      "combData": {
        "count": 229,
        "et": 1430971200000,
        "max": 4.664,
        "min": 0.131,
        "st": 1430881200000,
        "total": 89.369
      },
      "data": [{
        "count": 1,
        "et": 1430884800000,
        "max": 1.831,
        "min": 1.831,
        "st": 1430881200000,
        "total": 1.831
      }, {
        "count": 177,
        "et": 1430888400000,
        "max": 1.139,
        "min": 0.131,
        "st": 1430884800000,
        "total": 58.594
      }, {
        "count": 3,
        "et": 1430892000000,
        "max": 4.664,
        "min": 1.006,
        "st": 1430888400000,
        "total": 6.844
      }, {
        "count": 48,
        "et": 1430895600000,
        "max": 1.3,
        "min": 0.199,
        "st": 1430892000000,
        "total": 22.1
      }, {
        "count": 0,
        "et": 1430899200000,
        "max": 0,
        "min": 0,
        "st": 1430895600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430902800000,
        "max": 0,
        "min": 0,
        "st": 1430899200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430906400000,
        "max": 0,
        "min": 0,
        "st": 1430902800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430910000000,
        "max": 0,
        "min": 0,
        "st": 1430906400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430913600000,
        "max": 0,
        "min": 0,
        "st": 1430910000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430917200000,
        "max": 0,
        "min": 0,
        "st": 1430913600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430920800000,
        "max": 0,
        "min": 0,
        "st": 1430917200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430924400000,
        "max": 0,
        "min": 0,
        "st": 1430920800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430928000000,
        "max": 0,
        "min": 0,
        "st": 1430924400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430931600000,
        "max": 0,
        "min": 0,
        "st": 1430928000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430935200000,
        "max": 0,
        "min": 0,
        "st": 1430931600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430938800000,
        "max": 0,
        "min": 0,
        "st": 1430935200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430942400000,
        "max": 0,
        "min": 0,
        "st": 1430938800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430946000000,
        "max": 0,
        "min": 0,
        "st": 1430942400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430949600000,
        "max": 0,
        "min": 0,
        "st": 1430946000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430953200000,
        "max": 0,
        "min": 0,
        "st": 1430949600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430956800000,
        "max": 0,
        "min": 0,
        "st": 1430953200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430960400000,
        "max": 0,
        "min": 0,
        "st": 1430956800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430964000000,
        "max": 0,
        "min": 0,
        "st": 1430960400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430967600000,
        "max": 0,
        "min": 0,
        "st": 1430964000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430971200000,
        "max": 0,
        "min": 0,
        "st": 1430967600000,
        "total": 0
      }],
      "key": {
        "id": 64752,
        "name": "ForumDisplayPage#onCreate"
      }
    }, {
      "combData": {
        "count": 231,
        "et": 1430971200000,
        "max": 0.26,
        "min": 0.105,
        "st": 1430881200000,
        "total": 34.084
      },
      "data": [{
        "count": 1,
        "et": 1430884800000,
        "max": 0.157,
        "min": 0.157,
        "st": 1430881200000,
        "total": 0.157
      }, {
        "count": 179,
        "et": 1430888400000,
        "max": 0.227,
        "min": 0.105,
        "st": 1430884800000,
        "total": 25.006
      }, {
        "count": 3,
        "et": 1430892000000,
        "max": 0.26,
        "min": 0.167,
        "st": 1430888400000,
        "total": 0.631
      }, {
        "count": 48,
        "et": 1430895600000,
        "max": 0.258,
        "min": 0.143,
        "st": 1430892000000,
        "total": 8.29
      }, {
        "count": 0,
        "et": 1430899200000,
        "max": 0,
        "min": 0,
        "st": 1430895600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430902800000,
        "max": 0,
        "min": 0,
        "st": 1430899200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430906400000,
        "max": 0,
        "min": 0,
        "st": 1430902800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430910000000,
        "max": 0,
        "min": 0,
        "st": 1430906400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430913600000,
        "max": 0,
        "min": 0,
        "st": 1430910000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430917200000,
        "max": 0,
        "min": 0,
        "st": 1430913600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430920800000,
        "max": 0,
        "min": 0,
        "st": 1430917200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430924400000,
        "max": 0,
        "min": 0,
        "st": 1430920800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430928000000,
        "max": 0,
        "min": 0,
        "st": 1430924400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430931600000,
        "max": 0,
        "min": 0,
        "st": 1430928000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430935200000,
        "max": 0,
        "min": 0,
        "st": 1430931600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430938800000,
        "max": 0,
        "min": 0,
        "st": 1430935200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430942400000,
        "max": 0,
        "min": 0,
        "st": 1430938800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430946000000,
        "max": 0,
        "min": 0,
        "st": 1430942400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430949600000,
        "max": 0,
        "min": 0,
        "st": 1430946000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430953200000,
        "max": 0,
        "min": 0,
        "st": 1430949600000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430956800000,
        "max": 0,
        "min": 0,
        "st": 1430953200000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430960400000,
        "max": 0,
        "min": 0,
        "st": 1430956800000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430964000000,
        "max": 0,
        "min": 0,
        "st": 1430960400000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430967600000,
        "max": 0,
        "min": 0,
        "st": 1430964000000,
        "total": 0
      }, {
        "count": 0,
        "et": 1430971200000,
        "max": 0,
        "min": 0,
        "st": 1430967600000,
        "total": 0
      }],
      "key": {
        "id": 64743,
        "name": "MainActivity#onCreate"
      }
    }],
    "timeSpan": {
      "endTime": 1430971200000,
      "startTime": 1430881200000
    }
  })
}

function showTopbar(res) {
  res.json({
    timeSpan: {
      startTime: 1430971200000,
      endTime: 1430881200000
    },
    result: [{
      "combData": {
        "count": 8,
        "et": 1430755200000,
        "max": 45.737,
        "min": 0.682,
        "st": 1430668800000,
        "total": 138.721
      },
      "data": [{
        "count": 8,
        "et": 1430755200000,
        "max": 45.737,
        "min": 0.682,
        "st": 1430668800000,
        "total": 138.721
      }],
      "key": {
        "id": 119143,
        "name": " ShowThreadPage#onCreate"
      }
    }, {
      "combData": {
        "count": 178,
        "et": 1430755200000,
        "max": 31.217,
        "min": 0.657,
        "st": 1430668800000,
        "total": 876.807
      },
      "data": [{
        "count": 178,
        "et": 1430755200000,
        "max": 31.217,
        "min": 0.657,
        "st": 1430668800000,
        "total": 876.807
      }],
      "key": {
        "id": 119085,
        "name": " ForumDisplayPage#onCreate"
      }
    }, {
      "combData": {
        "count": 64,
        "et": 1430820000000,
        "max": 6.763,
        "min": 0.792,
        "st": 1430668800000,
        "total": 230.85500000000002
      },
      "data": [{
        "count": 64,
        "et": 1430820000000,
        "max": 6.763,
        "min": 0.792,
        "st": 1430668800000,
        "total": 230.85500000000002
      }],
      "key": {
        "id": 64737,
        "name": "ForumHomePage#onCreate"
      }
    }, {
      "combData": {
        "count": 140,
        "et": 1430755200000,
        "max": 9.908,
        "min": 0.812,
        "st": 1430668800000,
        "total": 412.903
      },
      "data": [{
        "count": 140,
        "et": 1430755200000,
        "max": 9.908,
        "min": 0.812,
        "st": 1430668800000,
        "total": 412.903
      }],
      "key": {
        "id": 119073,
        "name": " ForumHomePage#onCreate"
      }
    }, {
      "combData": {
        "count": 3,
        "et": 1430820000000,
        "max": 2.501,
        "min": 1.105,
        "st": 1430755200000,
        "total": 4.962
      },
      "data": [{
        "count": 3,
        "et": 1430820000000,
        "max": 2.501,
        "min": 1.105,
        "st": 1430755200000,
        "total": 4.962
      }],
      "key": {
        "alias": "ShowThreadPage",
        "id": 65914,
        "name": "ShowThreadPage#onCreate"
      }
    }, {
      "combData": {
        "count": 152,
        "et": 1430755200000,
        "max": 6.947,
        "min": 0.314,
        "st": 1430668800000,
        "total": 244.335
      },
      "data": [{
        "count": 152,
        "et": 1430755200000,
        "max": 6.947,
        "min": 0.314,
        "st": 1430668800000,
        "total": 244.335
      }],
      "key": {
        "id": 119087,
        "name": " SplashActivity#onCreate"
      }
    }, {
      "combData": {
        "count": 733,
        "et": 1430820000000,
        "max": 45.099,
        "min": 0.126,
        "st": 1430668800000,
        "total": 755.4180000000001
      },
      "data": [{
        "count": 733,
        "et": 1430820000000,
        "max": 45.099,
        "min": 0.126,
        "st": 1430668800000,
        "total": 755.4180000000001
      }],
      "key": {
        "id": 64752,
        "name": "ForumDisplayPage#onCreate"
      }
    }, {
      "combData": {
        "count": 1204,
        "et": 1430820000000,
        "max": 3.351,
        "min": 0.173,
        "st": 1430668800000,
        "total": 1008.53601
      },
      "data": [{
        "count": 1204,
        "et": 1430820000000,
        "max": 3.351,
        "min": 0.173,
        "st": 1430668800000,
        "total": 1008.53601
      }],
      "key": {
        "id": 64757,
        "name": "SplashActivity#onCreate"
      }
    }, {
      "combData": {
        "count": 162,
        "et": 1430755200000,
        "max": 4.237,
        "min": 0.07,
        "st": 1430668800000,
        "total": 122.634
      },
      "data": [{
        "count": 162,
        "et": 1430755200000,
        "max": 4.237,
        "min": 0.07,
        "st": 1430668800000,
        "total": 122.634
      }],
      "key": {
        "id": 119084,
        "name": " MainActivity#onCreate"
      }
    }, {
      "combData": {
        "count": 730,
        "et": 1430820000000,
        "max": 4.349,
        "min": 0.099,
        "st": 1430668800000,
        "total": 142.411
      },
      "data": [{
        "count": 730,
        "et": 1430820000000,
        "max": 4.349,
        "min": 0.099,
        "st": 1430668800000,
        "total": 142.411
      }],
      "key": {
        "id": 64743,
        "name": "MainActivity#onCreate"
      }
    }]
  })
}
